package com.qh.resourcehub.info.virtualresource.controller;

import com.qh.resourcehub.info.entity.ApplicationData;
import com.qh.resourcehub.info.virtualresource.service.VmSupervisorReviewSerivce;
import com.qh.resourcehub.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * IP 主任用户审核管理
 */
@RestController
@RequestMapping("/VmSupervisorReview")
public class VmSupervisorReviewController {
    @Autowired
    private VmSupervisorReviewSerivce vmSupervisorReviewSerivce;
    /**
     * 主任审核高级查询当前需要审核信息
     */
    @GetMapping("/queryVmReviewData")
    public ApiResponse queryVmReviewData(@RequestBody ApplicationData applicationData) {
        try {
            List<Map<String,Object>> i = vmSupervisorReviewSerivce.queryVmReviewData(applicationData);
            if (i.size()>0){
                return ApiResponse.succeed(i);
            }else {
                return ApiResponse.succeedNoData();
            }
        }catch (Exception e){
            return ApiResponse.succeedRequestNo();
        }
    }
    /**
     * 主任审核 通过
     */
    @GetMapping("/VmReviewPass")
    public ApiResponse VmReviewPass(@RequestBody ApplicationData applicationData) {
        try {
            int i = vmSupervisorReviewSerivce.VmReviewPass(applicationData);
            if (i>0){
                ApiResponse.succeedRequest();
            }else {
                return ApiResponse.succeedRequestNo();
            }
        }catch (Exception e){
            return ApiResponse.succeedRequestNo();
        }
        return ApiResponse.succeedRequestNo();
    }
    /**
     * 主任审核 驳回
     */
    @GetMapping("/VmReviewOverrule")
    public ApiResponse VmReviewOverrule(@RequestBody ApplicationData applicationData) {
        try {
            int i = vmSupervisorReviewSerivce.VmReviewOverrule(applicationData);
            if (i>0){
                ApiResponse.succeedRequest();
            }else {
                return ApiResponse.succeedRequestNo();
            }
        }catch (Exception e){
            return ApiResponse.succeedRequestNo();
        }
        return ApiResponse.succeedRequestNo();
    }
}
